package cli.tools;

/**
 * BudgetBuoy
 * 
 * Simplify your personal expense management
 * 
 * @team cs2103jan13-w15-3j
 */

//--------------------------------------------------------------

/**
 * Access.java
 * 
 * Description:
 *			
 * @package cli.tools
 * @author  Lai Yong Quan (A0080909Y)
 * @edited by: Tan Si Ling (A0085314J)
 */

import java.util.List;
import shared.Category;
import shared.Expense;
import shared.Income;
import shared.Loan;
import shared.Mode;
import shared.Payment;
import shared.Receipt;
import shared.Record;
import cli.menu.State;
import cli.tools.Process;
import cli.menu.Function;

//need to check returns of processDate, selectFromList, thrown exceptions

public class Access extends Function{

	private static String[] selectCat = {
		"[b]: back [u]: undo [r]: redo [h]: home menu",
	"Select a category by its index: "};
	private static String[] selectPaymentMode = {
		"[b]: back [u]: undo [r]: redo [h]: home menu",
	"Please select a Payment Mode by its index: "};
	private static String[] selectPaidInstallment = {
		"Paid installments for this loan: ",
	"Enter the index of an installment: "};
	private static String[] selectFutureInstallment = {
		"Future installments for this loan: ",
		"Enter the index of a future payment:"
	};



	//Precondition: @param Record object 
	//Postcondition: calls modRecord() with the Record that user wants to modify
	public static void modifyRecord(Record subject)  {
		cli.println("Would you like to modify this item? (Y/N)");
		String input = cli.nextLine();
		// we will only accept Y or y as yes and treat all others as no
		char charInput = input.charAt(0);
		switch (charInput) {
		case 'y':
		case 'Y':
			modRecord(subject);
		default:
			break;
		}

	}

	//Precondition: @param Payment object 
	//Postcondition: calls modPayment() with the Payment that user wants to modify
	private static void modifyPayment(Payment subject)  {
		cli.println("Would you like to modify this item? (Y/N)");
		String input = cli.nextLine();

		// we will only accept Y or y as yes and treat all others as no
		char charInput = input.charAt(0);
		switch (charInput) {
		case 'y':
		case 'Y':
			modPayment(subject);

		default:
			break;
		}

		return;
	}

	//Precondition: @param Payment object 
	//Postcondition: modifies the Amount/Date specified by the user
	//               @throws invalid input
	public static void modPayment(Payment subject)  {
		cli.println("What would you like to do?");
		cli.println("1. Modify Amount");
		cli.println("2. Modify Date");


		int option;
		try{
			option = cli.nextInt();
		}
		catch(Exception e){
			cli.print(INVALIDINPUT);		
			return;
		}
		cli.nextLine();

		String input;
		switch (option) {
		case 1:
			cli.print("Enter the new amount for this item: ");
			String value = cli.nextLine();
			int amount = tools.Money2int(value);
			if(amount <= 0){
				cli.println("Invalid amount entered, aborting");
				return ;
			}

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(subject.getAmt(), amount,
					Process.MODIFYFUTUREPAYMENTAMOUNT, subject);
			// **END**

			subject.modifyAmt(amount);

			break;
		case 2:
			cli.print("Enter the new Date of entry for this item (DD.MM.YYYY): ");

			input = cli.nextLine();
			int[] date = new int[3];
			try{
				date = tools.processDate(input);
			}
			catch(Exception e){
				cli.print(INVALIDDATE);
				date = tools.initDate();
			}
			// Si Ling: **Keeping Track of the Actions DONE**
			int[] oldDate = { subject.getDay(), subject.getMonth(),
					subject.getYear() };
			Tools.action.addToUndoStack(oldDate, date,
					Process.MODIFYFUTUREPAYMENTDATE, subject);
			// **END**

			subject.modifyDay(date[0]);
			subject.modifyMonth(date[1]);
			subject.modifyYear(date[2]);

			break;

		default:
			break;
		}

		return ;
	}

	//Precondition: @param Record object 
	//Postcondition:modifies the Record depending on the type
	//              of Record class 
	private static void modRecord(Record subject)  {
		if (subject.getClass() == Expense.class)
			modExpense((Expense) subject);
		else if (subject.getClass() == Income.class)
			modIncome((Income) subject);
		else if (subject.getClass() == Loan.class)
			modLoan((Loan) subject);
		else if (subject.getClass() == Receipt.class)
			modReceipt((Receipt) subject);
	}

	private static void modReceipt(Receipt subject){
		cli.println("What would you like to do?");
		cli.println("1. Modify Receipt Name");
		cli.println("2. Modify Total Amount");
		cli.println("3. Modify Date of Entry");
		cli.println("4. Modify Description");
		cli.println("5. Modify Shop Name");
		cli.println("6. Modify Receipt Number");
		cli.println("7. Modify Contact Number");
		cli.println("8. Modify Items");
		cli.println("9. Delete this item");

		int option;
		try{
			option = cli.nextInt();
		}
		catch(Exception e){

			cli.print(INVALIDINPUT);
			return;
		}
		cli.nextLine();

		String input;

		switch (option) {

		case 1:
			cli.print("Enter the new name for this receipt: ");
			input = cli.nextLine();

			// Si Ling: **Keeping Track of the Actions DONE**

			// **END**


			try {
				cli.getApi().modifyName(subject, input);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		case 2:
			cli.print("Enter the new total amount for this receipt: ");
			String value = cli.nextLine();
			int amount = tools.Money2int(value);

			if(amount <= 0){
				cli.println("Bad amount entered, aborting");
				return;
			}

			// Si Ling: **Keeping Track of the Actions DONE**

			// **END**

			try {
				cli.getApi().modifyExpenseAmount(subject, amount);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				cli.print(ERROR);
			}

			break;

		case 3:
			cli.print("Enter the new Date of entry for this receipt (DD.MM.YYYY): ");
			input = cli.nextLine();

			int[] date = new int[3];

			try {
				date = tools.processDate(input);
			} catch (Exception e1) {
				cli.print(INVALIDDATE);
				date = tools.initDate();
			}

			// Si Ling: **Keeping Track of the Actions DONE**

			// **END**

			try {
				cli.getApi().modifyDate(subject, date[0], date[1], date[2]);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		case 4:
			cli.print("Enter the new description for this receipt: ");
			input = cli.nextLine();

			// Si Ling: **Keeping Track of the Actions DONE**
			//modify description for income
			Tools.action.addToUndoStack((Object)subject.getDetail() , (Object) input,
					Process.MODIFYDESCRIPTION, (Object) subject);
			// **END**

			cli.getApi().modifyDescription(subject, input);
			break;

		case 5:

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(subject,null,
					Process.DELETEINCOME, null);
			// **END**

			try {
				cli.getApi().deleteIncome(subject);
			} catch (Exception e) {
				cli.print(ERROR);
			}


			break;

		default:
			cli.print(INVALIDINPUT);
			break;
		}
	}

	//Precondition: @param Income object
	//Postcondition: modifies the Income fields depending on user
	//              @throws invalid input
	private static void modIncome(Income subject)  {
		cli.println("What would you like to do?");
		cli.println("1. Modify Name");
		cli.println("2. Modify Amount");
		cli.println("3. Modify Date of entry");
		cli.println("4. Modify Description");
		cli.println("5. Delete this item");

		int option;
		try{
			option = cli.nextInt();
		}
		catch(Exception e){

			cli.print(INVALIDINPUT);
			return;
		}
		cli.nextLine();

		String input;

		switch (option) {

		case 1:
			cli.print("Enter the new name for this item: ");
			input = cli.nextLine();

			// Si Ling: **Keeping Track of the Actions DONE**

			Tools.action.addToUndoStack(subject.getName(),input,
					Process.MODIFYINCOMENAME,subject);
			// **END**


			try {
				cli.getApi().modifyIncomeName(subject, input);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		case 2:
			cli.print("Enter the new amount for this item: ");
			String value = cli.nextLine();
			int amount = tools.Money2int(value);

			if(amount <= 0){
				cli.println("Bad amount entered, aborting");
				return;
			}

			// Si Ling: **Keeping Track of the Actions DONE**

			Tools.action.addToUndoStack(subject.getAmt(), (Object) amount,
					Process.MODIFYINCOMEAMOUNT, subject);
			// **END**

			try {
				cli.getApi().modifyIncomeAmount(subject, amount);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		case 3:
			cli.print("Enter the new Date of entry for this item (DD.MM.YYYY): ");
			input = cli.nextLine();

			int[] date = new int[3];

			try {
				date = tools.processDate(input);
			} catch (Exception e1) {
				cli.print(INVALIDDATE);
				date = tools.initDate();
			}

			// Si Ling: **Keeping Track of the Actions DONE**

			int[] oldIncomeDate = { subject.getDay(), subject.getMonth(),
					subject.getYear() };

			Tools.action.addToUndoStack((Object) oldIncomeDate, (Object) date,
					Process.MODIFYINCOMEDATE, (Object) subject);
			// **END**

			try {
				cli.getApi().modifyDate(subject, date[0], date[1], date[2]);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		case 4:
			cli.print("Enter the new description for this item: ");
			input = cli.nextLine();

			// Si Ling: **Keeping Track of the Actions DONE**
			//modify description for income
			Tools.action.addToUndoStack((Object)subject.getDetail() , (Object) input,
					Process.MODIFYDESCRIPTION, (Object) subject);
			// **END**

			cli.getApi().modifyDescription(subject, input);
			break;

		case 5:

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(subject,null,
					Process.DELETEINCOME, null);
			// **END**

			try {
				cli.getApi().deleteIncome(subject);
			} catch (Exception e) {
				cli.print(ERROR);
			}


			break;

		default:
			cli.print(INVALIDINPUT);
			break;
		}

	}

	////Precondition: @param Expense object 
	//Postcondition: modifies the Expense fields as specified by the user
	//               @throws invalid input
	private static void modExpense(Expense subject)  {
		cli.println("What would you like to do?");
		cli.println("1. Modify Name");
		cli.println("2. Change Category");
		cli.println("3. Change Payment Mode");
		cli.println("4. Modify Amount");
		cli.println("5. Modify Date of entry");
		cli.println("6. Modify Description");
		cli.println("7. Delete this item");

		int option;
		try{
			option = cli.nextInt();
		}
		catch(Exception e){

			cli.print(INVALIDINPUT);
			return;
		}
		cli.nextLine();

		String input;

		switch (option) {
		case 1:
			cli.print("Enter the new name for this item: ");
			input = cli.nextLine();

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack((Object) subject.getName(), (Object) input,
					Process.MODIFYEXPENSENAME, subject);
			// **END**

			try {
				cli.getApi().modifyName(subject, input);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		case 2:
			Category category = null;
			//cli.println("Select a category by its index: ");
			Object choice = tools.selectFromList(cli.getApi().getCategoryList(), "Category",selectCat);

			//if back signal
			if(choice == null){
				return;
			}

			//if home or another instruction call
			if(choice.getClass() == State.class){
				//home call not supported yet
				return;
			}

			//if correct object received
			if(choice.getClass() == Category.class){
				category = (Category)choice;
			}

			subject.modifyCat(category);

			cli.println("Done");
			break;

		case 3:
			//cli.println("[b]: back [u]: undo [r]: redo [h]: home menu");
			//cli.println("Please select a Payment Mode by its index: ");

			choice = tools.selectFromList(cli.getApi().getModeList(),
					"modExpense", selectPaymentMode);

			//if back
			if(choice == null){
				return;
			}

			//if home or another instruction call
			if(choice.getClass() == State.class){
				//home call not supported yet
				return;
			}

			Mode paymentMode = (Mode)choice;

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(subject.getMode(), paymentMode,
					Process.MODIFYEXPENSEPAYMENTMODES, (Object) subject);
			// **END***

			subject.modifyMode(paymentMode);
			cli.println("Done");
			break;

		case 4:
			cli.print("Enter the new amount for this item: ");
			String value = cli.nextLine();
			int amount = tools.Money2int(value);

			if(amount<= 0){
				cli.println("Bad amount entered, aborting");
				return;
			}
			// Si Ling: **Keeping Track of the Actions DONE**

			Tools.action.addToUndoStack(subject.getAmt(), amount,
					Process.MODIFYEXPENSEAMOUNT, (Object) subject);
			// **END**

			try {
				cli.getApi().modifyExpenseAmount(subject, amount);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		case 5:
			cli
			.print("Enter the new Date of entry for this item (DD.MM.YYYY): ");
			input = cli.nextLine();

			int[] date = new int[3];

			try {
				date = tools.processDate(input);
			} catch (Exception e) {
				cli.print(INVALIDDATE);
				date = tools.initDate();
			}

			// Si Ling: **Keeping Track of the Actions DONE**

			int[] oldExpenseDate = { subject.getDay(), subject.getMonth(),
					subject.getYear() };

			Tools.action.addToUndoStack(oldExpenseDate,date,
					Process.MODIFYEXPENSEDATE, subject);
			// **END**

			try {
				cli.getApi().modifyDate(subject, date[0], date[1], date[2]);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		case 6:
			cli.print("Enter the new description for this item: ");
			input = cli.nextLine();

			// Si Ling: **Keeping Track of the Actions DONE**

			Tools.action.addToUndoStack((Object) subject.getDetail(), (Object) input,
					Process.MODIFYDESCRIPTION, (Object) subject);
			// **END**

			cli.getApi().modifyDescription(subject, input);

			break;

		case 7:

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(subject,null,
					Process.DELETEEXPENSE,null);
			// **END**

			try {
				cli.getApi().deleteExpense(subject);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;

		default:
			cli.print(INVALIDINPUT);
			break;
		}
	}

	//Precondition: @param Loan object 
	//Postcondition: modifies all the Loan field 
	//               @throws invalid input
	private static void modLoan(Loan subject) {
		cli.println("What would you like to do?");
		cli.println("1. Modify Name");
		cli.println("2. Change Category");
		cli.println("3. Modify Amount");
		cli.println("4. Modify Date of entry");
		cli.println("5. Modify Description");
		cli.println("6. View paid installments");
		cli.println("7. View future payment");
		cli.println("8. Set future payment");
		cli.println("9. Remove a future payment");
		cli.println("10. Clear Loan");
		cli.println("11. Unclear Loan");
		cli.println("12. Delete this item");

		int option;
		try{
			option = cli.nextInt();
		}
		catch(Exception e){

			cli.print(INVALIDINPUT);
			return;
		}
		cli.nextLine();

		int[] date;
		String input;

		switch (option) {
		case 1:
			cli.print("Enter the new name for this item: ");
			input = cli.nextLine();

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(subject.getName(),input,
					Process.MODIFYLOANNAME, subject);
			// **END**

			try {
				cli.getApi().modifyName(subject, input);
			} catch (Exception e) {
				cli.print(ERROR);
			}

			break;
		case 2:
			Category category = null;
			//			cli.println("[b]: back [u]: undo [r]: redo [h]: home menu");
			//			cli.println("Please select a category by its index: ");
			Object choice = tools.selectFromList(cli.getApi().getCategoryList(), "Category",selectCat);
			//if back
			if(choice == null){
				return;
			}
			//if redirection
			if(choice.getClass() == State.class){
				//not supported yet
				return;
			}
			if(choice.getClass() == Category.class){
				//not supported yet
				category = (Category)choice;

			}

			// Si Ling: **Keeping Track of the Actions DONE**

			Tools.action.addToUndoStack(subject.getCat(), category, Process.MODIFYCATEGORY,subject);

			// **END**

			subject.modifyCategory(category);

			cli.println("Done");
			break;

		case 3:
			cli.print("Enter the new amount for this item: ");
			String value = cli.nextLine();
			int amount = tools.Money2int(value);

			if(amount <= 0){
				cli.println("Bad amount entered, aborting...");
				return;
			}
			// Si Ling: **Keeping Track of the Actions DONE**

			Tools.action.addToUndoStack(subject.getAmt(), amount,
					Process.MODIFYLOANAMOUNT, subject); 
			// **END**
			try {
				cli.getApi().modifyLoanAmount(subject, amount);
			} catch (Exception e) {
				cli.print(ERROR);
			}
			break;
		case 4:
			cli
			.print("Enter the new Date of entry for this item (DD.MM.YYYY): ");
			input = cli.nextLine();

			try {
				date = tools.processDate(input);
			} catch (Exception e1) {
				cli.print(INVALIDDATE);
				date = tools.initDate();
			}

			// Si Ling: **Keeping Track of the Actions DONE**

			int[] oldLoanDate = { subject.getDay(), subject.getMonth(),
					subject.getYear() };

			Tools.action.addToUndoStack((Object) oldLoanDate, (Object) date,
					Process.MODIFYLOANDATE, (Object) subject);
			// **END**

			try {
				cli.getApi().modifyDate(subject, date[0], date[1], date[2]);
			} catch (Exception e) {
				cli.print(ERROR);
			}
			break;
		case 5:
			cli.print("Enter the new description for this item: ");
			input = cli.nextLine();

			// Si Ling: **Keeping Track of the Actions DONE**

			//modify description for loan
			Tools.action.addToUndoStack((Object) subject.getDetail(), (Object) input,
					Process.MODIFYDESCRIPTION, (Object) subject);
			//***END***
			cli.getApi().modifyDescription(subject, input);
			break;
		case 6:
			//			cli.println("Paid installments for this loan: ");
			//			cli	.println("Enter the index of an installment to view its details");
			//			Expense installment = (Expense) tools.selectFromList(installments,
			//					"Loans");
			List<Expense> installments = subject.getInstallments();
			choice = tools.selectFromList(installments,	"Loans", selectPaidInstallment);

			if(choice == null){
				return;
			}

			if(choice.getClass() == State.class){
				return;
			}

			Expense installment = (Expense)choice;
			viewExpense(installment);
			modifyRecord(installment);
			break;

		case 7:
			List<Payment> futureInstallments = subject.getFuturePayments();
			if(futureInstallments.size() <= 0){
				cli.println("There are no future payments for this loan");
			}
			cli.println("Future installments for this loan: ");
			cli.println("Enter the index of a future installment to modify it");
			//			Payment futurePayment = (Payment) tools.selectFromList(
			//					futureInstallments, "Loans");

			choice = tools.selectFromList(futureInstallments, "Future Payment", selectFutureInstallment);

			if(choice == null){
				return;
			}

			if(choice.getClass() == State.class){
				return;
			}

			Payment futurePayment = (Payment) choice;

			viewPayment(futurePayment);
			modifyPayment(futurePayment);


			break;

		case 8:
			cli.println("Setting future payment for this loan");
			cli.println("Enter the details in the following format");
			cli.println("Date (DD.MM.YYYY) / amount");
			input = cli.nextLine();
			String[] processing = input.split("/");

			try {
				date = tools.processDate(processing[0]);
			} catch (Exception e) {
				cli.print(INVALIDDATE);
				date = tools.initDate();
			}


			amount = tools.Money2int(processing[1]);

			if(amount <= 0){
				cli.println("Bad amount entered, aborting...");
				return;
			}


			Payment tempP = subject.addFuturePayment(amount, date[0], date[1], date[2]);
			// Si Ling: **Keeping Track of the Actions DONE**
			//Payment tempP = new Payment(amount, date);
			Tools.action.addToUndoStack( null, tempP,
					Process.ADDFUTUREPAYMENT_LOAN, subject);
			// **END**


			break;
		case 9:
			futureInstallments = subject.getFuturePayments();
			//			cli.println("Enter the index of a future payment to remove it");
			//			Payment toRemove = (Payment) tools.selectFromList(futureInstallments,
			//					"Loans");

			choice = tools.selectFromList(futureInstallments,"Loans",selectFutureInstallment);

			if(choice == null){
				return;
			}

			if(choice.getClass() == State.class){
				return;
			}

			Payment toRemove = (Payment)choice;

			futureInstallments.remove(toRemove);
			cli.println("Future payment removed");
			break;
		case 10:

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(null, null,
					Process.CLEARLOAN, subject);
			// **END**

			try {
				cli.getApi().clearLoan(subject);
			} catch (Exception e) {
				cli.print(ERROR);
			}
			break;

		case 11:

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(null, null,
					Process.UNCLEARLOAN, subject);
			// **END**	

			try {
				cli.getApi().unclearLoan(subject);
			} catch (Exception e) {
				cli.print(ERROR);
			}
			break;

		case 12:

			// Si Ling: **Keeping Track of the Actions DONE**
			Tools.action.addToUndoStack(subject, null,
					Process.DELETELOAN, null);
			// **END**

			try {
				cli.getApi().deleteLoan(subject);
			} catch (Exception e) {
				cli.print(ERROR);
			}
			break;

		default:
			cli.print(INVALIDINPUT);
			break;
		}
	}


	//Precondition:  @param Record object 
	//Postcondition: calls the respective classes that user wants 
	//               to view
	//               @throws invalid input
	public static void viewRecord(Record subject) {
		if (subject.getClass() == Expense.class)
			viewExpense((Expense) subject);
		else if (subject.getClass() == Income.class)
			viewIncome((Income) subject);
		else if (subject.getClass() == Loan.class)
			viewLoan((Loan) subject);
		else if (subject.getClass() == Receipt.class)
			viewReceipt((Receipt) subject);
	}

	//print receipt
	public static void viewReceipt(Receipt subject) {
		cli.println("-Receipt View-");
		cli.println("Date of Entry  : " + subject.getDay() + "."
				+ subject.getMonth() + "." + subject.getYear());
		cli.println("Name of Receipt: " + subject.getName());
		cli.println("Category       : " + subject.getCat().getName());
		cli.println("Mode of Payment: " + subject.getMode());
		cli.println("Details        : " + subject.getDetail());
		cli.println("-------------------print receipt below----------------------");
		cli.println("");
		cli.println("Shop Name  : "+subject.getSeller());
		cli.println("Receipt No.: "+subject.getReceiptNO());
		cli.println("Contact No.: "+subject.getContact());
		cli.println("");
		for(int i=0;i<subject.getItems().size();i++){
			cli.println(subject.getItems().get(i).toString());
		}
		cli.println("");
		cli.printf("Total Amount: $%.2f\n", (double) subject.getAmt() / 100.00);

	}


	//Prints the standard output to the user depending on the type. 
	private static void viewExpense(Expense subject) {
		cli.println("-Expense View-");
		cli.println("Date of Entry: " + subject.getDay() + "."
				+ subject.getMonth() + "." + subject.getYear());	
		cli.println("Name of Expense: " + subject.getName());
		cli.println("Category: " + subject.getCat().getName());
		cli.println("Mode of Payment: " + subject.getMode());
		cli.printf("Amount: $%.2f\n", (double) subject.getAmt() / 100.00);
		cli.println("Details: " + subject.getDetail());

	}

	private static void viewIncome(Income subject) {
		cli.println("-Income View-");
		cli.println("Date of Entry: " + subject.getDay() + "."
				+ subject.getMonth() + "." + subject.getYear());
		cli.println("Name of Income: " + subject.getName());
		cli.printf("Amount: $%.2f\n", (double) subject.getAmt() / 100.00);
		cli.println("Details: " + subject.getDetail());
	}

	private static void viewLoan(Loan subject) {
		cli.println("-Loan View-");
		cli.println("Date of Entry: " + subject.getDay() + "."
				+ subject.getMonth() + "." + subject.getYear());
		cli.println("Name of Loan: " + subject.getName());
		cli.println("Category: " + subject.getCat().getName());
		cli.printf("Amount: $%.2f\n", (double) subject.getAmt() / 100.00);
		cli.println("Details: " + subject.getDetail());

	}

	public static void viewPayment(Payment subject) {
		cli.println("-Loan View-");
		cli.println("Date of Entry: " + subject.getDay() + "."
				+ subject.getMonth() + "." + subject.getYear());
		cli		.printf("Amount: $%.2f\n", (double) subject.getAmt() / 100.00);
	}


}